package com.reconcile.phone.web.controller.call;

import com.reconcile.phone.business.domain.RpPhoneOrder;
import com.reconcile.phone.business.domain.bo.RpPhoneOrderBo;
import com.reconcile.phone.business.domain.vo.RpPhoneOrderVo;
import com.reconcile.phone.business.service.RpPhoneOrderService;
import com.reconcile.phone.common.annotation.RepeatSubmit;
import com.reconcile.phone.common.core.controller.BaseController;
import com.reconcile.phone.common.core.domain.R;
import com.reconcile.phone.common.core.validate.AddGroup;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * APP 订单管理
 * <p>
 * Author: liuliyou
 * Date: 2025/8/7
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/phone/mobile/phoneOrder")
public class RpPhoneOrderController extends BaseController {

    private final RpPhoneOrderService rpPhoneOrderService;

    /**
     * 新增订单
     *
     * @param bo 手机号信息
     * @return 新增结果
     */
    @RepeatSubmit(interval = 5, timeUnit = TimeUnit.SECONDS, message = "5s秒内请勿重复操作")
    @PostMapping
    public RpPhoneOrder add(@Validated(AddGroup.class) @RequestBody RpPhoneOrderBo bo) {
        return rpPhoneOrderService.insertPhoneOrder(bo);
    }


    /**
     * 订单查询
     *
     * @param bo
     * @return
     */
    @GetMapping("/list")
    public R<List<RpPhoneOrderVo>> list(RpPhoneOrderBo bo) {
        return R.ok(rpPhoneOrderService.selectPhoneOrderList(bo));
    }
}
